// From prototype.js @ www.conio.net | Returns an object reference to one or more strings
// ignore the fact that there are no arguments to this method -- javascript doesn't care how many you send (not strongly typed)
// The method checks the actual # of arguments -- returns a single object or an array
function $() {
    var elements = new Array();

    for (var i = 0; i < arguments.length; i++) {
        var element = arguments[i];

        if (typeof element == 'string')
            element = document.getElementById(element);

        if (arguments.length == 1)
            return element;

        elements.push(element);
    }

    return elements;
}


// handle some key press events
function handleKeyUp( e ) {
    e = (!e) ? window.event : e;
    target = (!e.target) ? e.srcElement : e.target;

    if (e.type == "keyup") {
        // skip shift, alt, control keys
        if (e.keyCode == 16 || e.keyCode == 17 || e.keyCode == 18) {
        // do nothing
        }

        else {
            if (target.name == "state1" && !$('state1').value) {
                clearCustomersByState();
            } else if (target.name == "state2" && !$('state2').value) {
                clearCustomersByStateXML();
            } else if (target.name == "google_search") {
                if (target.value) {
                    getSuggest(target);
                } else {
                    $('google_suggest_target').innerHTML = "";
                }
            }
        }
    }
}

function toggleDiv( element ) {
    var e = $(element);

    if (e) {
        e.style.display = ((e.style.display != 'block') ? 'block' : 'none');
        $('div_upper_right').innerHTML = _description[e.id]();
    }
}

function toggleDivD( element, element2, element3set, varelement3set ) {
    var e = $(element);
    var e2 = $(element2);
    var e3 = $(element3set);

    if (e) {
        e.style.display = ((e.style.display != 'block') ? 'block' : 'none');
    }
    
    if (e2) {
        e2.style.display = ((e2.style.display != 'block') ? 'block' : 'none');
    }
    if (e3) {
	e3.value = varelement3set;
    }

}

function toggleDivJQ( element, element2, element3set, varelement3set ) {
    jQuery.noConflict();
    
    
    //alert(jQuery(element).css("display"));
    //alert(jQuery(element2).css("display"));
    
    if (jQuery(element).css("display") == "none") {
	jQuery(element2).slideUp("slow");
	jQuery(element).slideDown("slow");
    } else {
	jQuery(element).slideUp("slow");
	jQuery(element2).slideDown("slow");
    }
    
    
    if (element3set) {
	jQuery(element3set).val(varelement3set);
	
    }
    
    //alert(element3set);
    //alert(jQuery(element3set).val());

}

function toggleLog( button ) {
	var disp=$('status_area').style.display;
	if ( disp == 'none' ) {
		$('status_area').style.display = 'block';
		button.value= 'Stop & Hide Log';
		_logger = true;
	} else {
		$('status_area').style.display = 'none';
		button.value= 'Show Log';
		_logger = false;
	}
}


